1. Field of the Invention
The present invention relates generally to an improved data processing system and in particular to the efficient compilation of computer usable program code. Still more particularly, the present invention relates to performing precise profiling techniques in a multi-threaded dynamic compilation environment.
2. Description of the Related Art
Compilers are software programs that modify a second program. For example, a compiler can transform a computer program written in a language more easily understandable to humans into a language more easily used by a computer. In this example, a compiler is said to compile source code into executable code.
However, compilers have a wide variety of applications in modifying programs. In another example, optimizing compilers can be used to optimize existing code, whether or not that existing code is source code or executable code. For example, an optimizing compiler can profile existing code to identify and, optionally, automatically change, existing portions of inefficient code so that the existing code operates more efficiently or more quickly.
Additionally, some modern compilers can operate on a program while it is being executed. This type of compiler is referred to as a dynamic compiler, and computer programming languages that are designed to support such activity may be referred to as “dynamically compiled languages”.
Some modern compilers also use a technique known as profiling to improve the quality of code generated by the compiler. An example of a profiling technique is profile directed feedback (PDF). Profiling is usually performed by adding relevant instrumentation code to the program being compiled, and then executing that program to collect profiling data. Examples of profiling data include relative frequency of execution of one part of the program compared to others, values of expressions used in the program, and outcomes of conditional branches in the program. The optimizing compiler can use this data to perform code reordering, based on relative block execution frequencies, code specialization, based on value profiling, code block outlining, or other forms of optimization techniques that boost the final program's performance.
However, advances in computer technology have affected profiling techniques in optimizing compilers. Some modern computers are capable of supporting a technology known as multi-threading. In programming, a thread is a part of a program that can execute independently of other parts of the program. Operating systems that support multi-threading enable programmers to design programs whose threaded parts can execute concurrently. Sometimes, a portion of a program being concurrently executed is also referred to as a thread, as can the portion of the data processing system's resources dedicated to controlling the execution of that portion of the program.
In data processing systems that operate multiple threads of a program, current optimizing compilers are unable to synchronize multiple threads efficiently when the multiple threads manipulate global data. The problem arises because of tradeoff between resource cost and accuracy. Purely static profiling systems have found generating fully thread-safe code to be too costly, and thus have reduced accuracy and the inability to gather either thread-specific or invocation-specific data to drive their optimization decisions. In dynamic compilation, where profiling resource costs must be paid at runtime, the stakes are even higher. The stakes are higher because of the presence of globally visible profiling control variables that are used to limit the cost of dynamic profiling and because of the need to eliminate race conditions to avoid becoming stuck in profiling mode. For this reason, devices and methods are desired whereby goals in limiting profiling cost can be met while still providing accurate profiling data and the ability to gather both thread-specific and invocation-specific profile data. Thus, advances in computer technology have required advances in profiling techniques for optimizing compilers.